﻿using System;
using System.Collections.Generic;
using System.Text;
using Dispatcher;
using System.IO;

namespace DispatcherTest
{
    public class TestTask : ITask
    {
        private DispatchInterval interval;

        public TestTask()
        {
            this.interval = DispatchInterval.MINUTELY;
        }

        #region ITask Members

        public bool Execute()
        {
            try
            {
                Object[] foo = { DateTime.Now, this.interval.ToString() };
                StreamWriter writer = new StreamWriter(@"C:\test.txt", true);
                writer.Write("Running... {0} at {1}", foo);
                writer.Write(writer.NewLine);
                writer.Close();
                return true;
            }

            catch (Exception e)
            {
                return false;
            }
        }

        public string Name
        {
            get { return "TestTask"; }
        }

        public DispatchInterval Interval
        {
            get { return this.interval; }
        }

        #endregion
    }
}
